/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skelbkim;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

/**
 *
 * @author laimis
 */
public class Skelbkime extends SeleneseTestCase {

    public void setUp() throws Exception {
        setUp("http://www.skelbkime.lt/", "*firefox");
    }

    public void newNotation(String noticeText, String phone, String name, String noticeTitle, String email) throws Exception {
        selenium.open("/");
        selenium.click("link=NAUJAS SKELBIMAS");
        if (isPageLoude()) {
            selenium.select("menu1", "label=Web svetainių reklama");
            selenium.select("menu1", "label=Įvairios paslaugos");
            selenium.select("Įvairios paslaugos", "label=WEB sprendimai");
            selenium.select("form_action", "label=Siūlau");
            selenium.type("form_subject", noticeTitle);
            selenium.type("form_name", name);
            selenium.type("form_email", email);
            selenium.click("policy");
            selenium.type("//*[@id=\"form_msg\"]", noticeText);
            selenium.click("//input[@value='S k e l b t i']");
        }
        selenium.stop();
    }

    private boolean isPageLoude() {
        boolean result = true;
        while (!selenium.isElementPresent("//table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr/td/div/form/table/tbody/tr[21]/td[2]/input")) {
            selenium.waitForPageToLoad("5000");
        }
        return result;
    }
}

